#include <cppunit/config/SourcePrefix.h>
#include "TestDesignEntity.h"
#include <string>

void TestDesignEntity::setUp() {
}

void TestDesignEntity::tearDown() {
	delete DE;
}

CPPUNIT_TEST_SUITE_REGISTRATION( TestDesignEntity );

void TestDesignEntity::testConstant(){
	DE = new Constant(42);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Constant created", CONSTANT, DE->getType());
	Constant *Co = dynamic_cast<Constant*>(DE);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("Constant contains correct value", 42, Co->getValue());
}

void TestDesignEntity::testVariable(){
	DE = new Variable(42);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Variable created", VARIABLE, DE->getType());
	Variable *Var = dynamic_cast<Variable*>(DE);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("Variable contains correct index", 42, Var->getIndex());
}

void TestDesignEntity::testProcedure(){
	DE = new Procedure(42);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Procedure created", PROCEDURE, DE->getType());
	Procedure *Var = dynamic_cast<Procedure*>(DE);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("Procedure contains correct index", 42, Var->getIndex());
}

void TestDesignEntity::testStmtList(){
	DE = new StmtList();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type StmtList created", STMTLIST, DE->getType());
}

void TestDesignEntity::testAssign(){
	DE = new Assign();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Assign created", ASSIGN, DE->getType());
}

void TestDesignEntity::testWhile(){
	DE = new While();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type While created", WHILE, DE->getType());
}

void TestDesignEntity::testPlus(){
	DE = new Plus();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Plus created", PLUS, DE->getType());
}

void TestDesignEntity::testMinus(){
	DE = new Minus();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Minus created", MINUS, DE->getType());
}

void TestDesignEntity::testTimes(){
	DE = new Times();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Times created", TIMES, DE->getType());
}

void TestDesignEntity::testProgram(){
	DE = new Program();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Program created", PROGRAM, DE->getType());
}

void TestDesignEntity::testCall(){
	DE = new Call(42);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type Call created", CALL, DE->getType());
	Call *Var = dynamic_cast<Call*>(DE);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("Call contains correct procIndex", 42, Var->getProcIndex());
}
	
void TestDesignEntity::testIf(){
	DE = new If();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("DesignEntity of type If created", IF, DE->getType());
}